<template>
  <div>
    <SearchTable
      :data="searchList"
    />
  </div>
</template>

<script>
  import SearchTable from '../../components/search/SearchTable.vue';
  import { searchCategoryList } from "../../api";
  import {showToast} from '../../api/wechat';
  export default {
    name: "searchList",
    components : {
      SearchTable,
    },
    data(){
      return {
        searchList : [],
        page : 1,
      };
    },
    mounted(){
      this.searchList = [];
      this.page = 1;
      this.getSearchList(this.page);
    },
    methods :{
      getSearchList(page){
        let category = this.$route.query.category;
        let key = this.$route.query.params || 'category';
        let value = this.$route.query.value || category;
        searchCategoryList(key,value,page).then(response => {
          this.searchList.push(...response.data.data);
          if (response.data.data.length === 0) {
            showToast('没有更多数据');
          }
        });
      },

    },
    onReachBottom(){
      this.page++;
      this.getSearchList(this.page);
    },
  };
</script>

<style scoped>

</style>
